package com.etc.service.impl;

import com.etc.dao.TimeMapper;
import com.etc.entity.Time;
import com.etc.service.TimeService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TimeServiceImpl implements TimeService {
    @Autowired
    private TimeMapper timeMapper;


    @Override
    public int addTime(List<Time> timeList) {
        int i = timeMapper.insertTimeList(timeList);
        //返回受影响行数
        return i;
    }

    @Override
    public List<Time> getDoctorTimeByRange(String doctorId, String date) {
        //设置第七天
        String lastDay = new DateTime(date).plusDays(6).toString("yyyy-MM-dd");
        List<Time> times = timeMapper.findTimeByDoctorIdAndDate(doctorId, date, lastDay);
        return times;

    }
}
